package org.zfes.snowier.zbss.xzy.router.others;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.zfes.snowier.core.data.DataSet;
import org.zfes.snowier.web.controller.BaseController;
import org.zfes.snowier.zbss.xzy.biz.config.model.ConfigRecord;
import org.zfes.snowier.zbss.xzy.biz.config.service.IConfigRecordService;
import org.zfes.snowier.core.data.SelectVo;
@Controller 
@RequestMapping("/xzy")
public class ConfigRecordController implements BaseController {

	
	@Autowired
	private IConfigRecordService configRecordService;
	
	//@RequiresPermissions(value="configRecord:loadConfigRecordDataSet",desc="配置记录列表")
    @RequestMapping(value="/loadConfigRecordDataSet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadConfigRecordDataSet(@RequestBody Map<String,Object> params){
	    DataSet dataSet=  configRecordService.loadConfigRecordDataSet(params);
	    return ajaxQuery("dataSet", dataSet);
    }
	
	//@RequiresPermissions(value="configRecord:createConfigRecord",desc="配置记录添加")
    @RequestMapping(value="/createConfigRecord", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public  @ResponseBody Object createConfigRecord(@RequestBody ConfigRecord configRecord){
		configRecordService.createConfigRecord(configRecord);
    	return ajaxDoneSuccess("数据操作成功 ");
    }
	
	//@RequiresPermissions(value="configRecord:loadConfigRecord",desc="配置记录加载")
    @RequestMapping(value="/loadConfigRecord/{id}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadConfigRecord(@PathVariable("id")Long id){
		Optional<ConfigRecord> ops = configRecordService.loadConfigRecordById(id);
		return ajaxQuery("configRecord",ops);
    }
	
	//@RequiresPermissions(value="configRecord:updateConfigRecord",desc="配置记录更新")
    @RequestMapping(value="/updateConfigRecord", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object updateConfigRecord(@RequestBody  ConfigRecord configRecord){
		configRecordService.updateConfigRecord(configRecord);
		return ajaxDoneSuccess("数据操作成功 ");
    }
	
	//@RequiresPermissions(value="configRecord:deletConfigRecord",desc="配置记录删除")
    @RequestMapping(value="/deleteConfigRecord/{id}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object deleteConfigRecord(@PathVariable("id")Long id){
		configRecordService.deleteConfigRecord(id);
		return ajaxDoneSuccess("数据操作成功 ");
    }


    @RequestMapping(value="/loadConfigRecordSelectVo", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadConfigRecordSelectVo(){
		 List<SelectVo>  ops = configRecordService.loadConfigRecordSelectVo("");
		return ajaxQuery("selectVo",ops);
    }
    
}